# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libdvbpsi
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3.3
pkgrel=1
pkgdesc="A library designed for decoding and generation of MPEG TS and DVB PSI tables (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://www.videolan.org/developers/libdvbpsi.html"
license=("LGPL2.1")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
options=('staticlibs' 'strip')
source=("https://download.videolan.org/pub/${_realname}/${pkgver}/${_realname}-${pkgver}.tar.bz2")
sha256sums=('02b5998bcf289cdfbd8757bedd5987e681309b0a25b3ffe6cebae599f7a00112')

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-release

  make SUBDIRS=src
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p ${pkgdir}${MINGW_PREFIX}/{bin,lib,include}
  make -j1 SUBDIRS=src DESTDIR="${pkgdir}" install
}
